using System;
using System.Diagnostics;
using System.Web;

namespace SearchTools.Logging
{
    internal sealed class Logger
    {
        private Logger()
        {
        }

        public static void Write(string message)
        {
            if (HttpContext.Current == null)
                Trace.WriteLine(message);
            else
                HttpContext.Current.Trace.Write(message);
        }

        public static void Write(string category, string message)
        {
            if (HttpContext.Current == null)
                Trace.WriteLine(message, category);
            else
                HttpContext.Current.Trace.Write(category, message);
        }

        public static void Write(string category, string message, Exception e)
        {
            if (HttpContext.Current == null)
            {
                Trace.WriteLine(message, category);
                Trace.WriteLine(e.ToString());
            }
            else
                HttpContext.Current.Trace.Write(category, message, e);
        }
    }
}